﻿<UserControl
	x:Class="RIBA.MainPage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:MVVMSL="clr-namespace:Riba.MVVMSL;assembly=RibaMVVMSL"
	xmlns:me="clr-namespace:RIBA.Helper"
	xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
	mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="700"
	DataContext="{Binding Source={StaticResource App_ViewModelLocator}, Converter={StaticResource App_ViewModelNameToViewModelConverter}, ConverterParameter=RIBA.MainPage_VM}"
>
	<UserControl.Resources>
		<me:IsParameterEqualBindedValue_Converter x:Key="IsParameterEqualBindedValue_Conv"></me:IsParameterEqualBindedValue_Converter>
	</UserControl.Resources>

	<Border BorderThickness="1" CornerRadius="1" Padding="1">
		<Border.BorderBrush>
			<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
				<GradientStop Color="Black" Offset="0" />
				<GradientStop Color="#FFA0A0A0" Offset="1" />
			</LinearGradientBrush>
		</Border.BorderBrush>

		<Grid Background="#0FFFFFCB">
			<Grid.RowDefinitions>
				<RowDefinition Height="34" />
				<RowDefinition />
				<RowDefinition Height="24" />
			</Grid.RowDefinitions>

			<Border BorderThickness="1" BorderBrush="#FFB4B9D1" CornerRadius="1" Padding="1">
				<Border.Background>
					<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
						<GradientStop Color="#FFD6E5EF" Offset="0" />
						<GradientStop Color="#FF41A1D4" Offset="1" />
					</LinearGradientBrush>
				</Border.Background>
				
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*"></ColumnDefinition>
						<ColumnDefinition Width="Auto"></ColumnDefinition>
						<ColumnDefinition Width="70"></ColumnDefinition>
					</Grid.ColumnDefinitions>

					<StackPanel Orientation="Horizontal" Height="24">
						<Button
							Content="{Binding Path=TextResource.ServerTime, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandMenu}"
							CommandParameter="100"
						/>
						<Button
							Content="{Binding Path=TextResource.ServerTimeTimeout, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandMenu}"
							CommandParameter="15000"
						/>
						<Button
							Content="{Binding Path=TextResource.ToLongAnswer, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandMenu}"
							CommandParameter="GetLongAnswer"
						/>
						<Button
							Content="{Binding Path=TextResource.AdminOnly, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandMenu}"
							CommandParameter="AdminOnly"
							IsEnabled="{Binding IsAdmin}"
						/>
					</StackPanel>

					<StackPanel Orientation="Horizontal" Grid.Column="1" Height="24" HorizontalAlignment="Right">
						<TextBlock
							Text="{Binding Path=WebContext.Authentication.User.Name, Source={StaticResource App_WebContextWrapper}}"
							VerticalAlignment="Center"
							Padding="0,0,5,0"
						/>
						<TextBlock
							Text="{Binding Roles}"
							VerticalAlignment="Center"
							Padding="0,0,5,0"
						/>
						<Button
							Content="{Binding LoginButtonText}"
							Command="{Binding CommandLogin}"
						/>
					</StackPanel>

					<StackPanel FlowDirection="LeftToRight" Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="2" Height="24">
						<Button
							Content="{Binding Path=TextResource.DE, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandLanguage}"
							CommandParameter="de"
							IsEnabled="{Binding CurrentLanguage, Converter={StaticResource IsParameterEqualBindedValue_Conv}, ConverterParameter='de'}"
							Padding="3,0,3,0"
						/>
						<Button 
							Content="{Binding Path=TextResource.FR, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandLanguage}"
							CommandParameter="fr"
							IsEnabled="{Binding CurrentLanguage, Converter={StaticResource IsParameterEqualBindedValue_Conv}, ConverterParameter='fr'}"
							Padding="3,0,3,0"
						/>
						<Button
							Content="{Binding Path=TextResource.EN, Source={StaticResource App_TextResourceWrapper}}"
							Command="{Binding CommandLanguage}"
							CommandParameter="en"
							IsEnabled="{Binding CurrentLanguage, Converter={StaticResource IsParameterEqualBindedValue_Conv}, ConverterParameter='en'}"
							Padding="3,0,3,0"
						/>
					</StackPanel>
				</Grid>
			</Border>

			<Border BorderThickness="1" BorderBrush="#FFB4B9D1" CornerRadius="1" Padding="1" Grid.Row="1">
				<MVVMSL:NavigatorControl
					IsDirtyQuestion="{Binding Path=TextResource.IsDirtyQuestion, Source={StaticResource App_TextResourceWrapper}}"
					IsDirtyQuestionCaption="{Binding Path=TextResource.IsDirtyQuestionCaption, Source={StaticResource App_TextResourceWrapper}}"
					ContinueNavigationButtonCaption="{Binding Path=TextResource.ContinueNavigationButtonCaption, Source={StaticResource App_TextResourceWrapper}}"
					CancelNavigationButtonCaption="{Binding Path=TextResource.CancelNavigationButtonCaption, Source={StaticResource App_TextResourceWrapper}}"
				/>
			</Border>

			<TextBlock Text="{Binding Counter}" Grid.Row="1" FontSize="72" />

			<Border BorderThickness="1" BorderBrush="#FFB4B9D1" CornerRadius="1" Padding="1" Grid.Row="2">
				<Grid Grid.Row="2" Background="AliceBlue">
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Status}" VerticalAlignment="Center" />
					<TextBlock Text="{Binding Version}" VerticalAlignment="Center" Grid.Column="1" />
				</Grid>
			</Border>

			<toolkit:BusyIndicator
				BusyContent="{Binding Path=TextResource.PleaseWait, Source={StaticResource App_TextResourceWrapper}}" 
				IsBusy="{Binding IsBusy}"
				Grid.RowSpan="3"
			/>
		</Grid>
	</Border>
</UserControl>